package com.tutorialspoint;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import org.springframework.core.io.ClassPathResource;

public class MainApp {
	public static void main(String[] args) {
		//创建应用程序的上下文,容器从classpath中所搜bean配置文件，所以填写相对路径即可
//		ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");
		//创建应用程序的上下文,需要提供xml文件的完整路径
		ApplicationContext context = 
				new FileSystemXmlApplicationContext("D:/Applications/Work/Workspace/HelloSpring/src/main/java/beans.xml");
		//没有手动new对象，使用context的getBean方法获取bean,这个bean的ID返回一个可以转换为实际对象的通用对象
		HelloWorld obj = (HelloWorld) context.getBean("helloWorld");
		
//		BeanFactory factory = null;
//		FileSystemXmlApplicationContext fc = null;
		obj.getMessage();
	}
}
